//
// Created by francklinson on 2021/10/21 AT 15:26.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    int minMovesToSeat(vector<int> &seats, vector<int> &students) {
        sort(seats.begin(),seats.end());
        sort(students.begin(),students.end());
        int ans = 0;
        for (int i = 0; i < seats.size(); ++i) {
            ans += abs(seats[i]-students[i]);
        }
        return ans;
    }
};

int main() {
    vector<int> seats{3, 1, 5};
    vector<int> students{2, 7, 4};
    Solution solution;
    cout << solution.minMovesToSeat(seats, students) << endl;
    return 0;
}

